const curry = (fn, ...arg1) => {
    return function partial(...arg2) {
        let comboArgs = [...arg1, ...arg2];
        if(comboArgs.length === fn.length){
            return fn(...comboArgs);
        } else {
            return curry(fn, ...comboArgs);
        }
    };
}

const curryAdd = curry((a, b, c, d) => a + b + c + d);
const res = curryAdd(8)(6)(7)(3);
console.log(res);

function fetch(url, data){ 
    return new Promise((resolve) => {
        setTimeout(resolve, 1000, {url, data});
    });
}
const fetchInfo = curry(fetch)('/api/userinfo');
fetchInfo({uid: 10086}).then((res) => { console.log(res);});
fetchInfo({uid: 10087}).then((res) => { console.log(res);});
fetchInfo({uid: 10088}).then((res) => { console.log(res);});


// const curry = (fn, ...args) => {
//     return function tmp(...args2){
//         let comboArgs = [...args, ...args2];
//         if(comboArgs.length >= fn.length){
//             return fn(...comboArgs);
//         } else {
//             return curry(fn, ...comboArgs);
//         }
//     }
// }

// let curry2Add = curry((a, b, c, d) => a + b + c + d, 5);
// curry2Add = curry2Add(10, 100);
// console.log('@@@@@@', curry2Add(1000));
// console.log('@@@@@@', curry2Add(2000));


// const complateRender = (templateStr, data) => {
//     console.log('渲染模板文件', templateStr);
// }
// const complieUser = curry(complateRender)('/tpl/user.tpl');
// complieUser({name: 'lion', age: '34', work: '10'});
